<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>交互式会计准则学习：核算方法转换</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <!-- Chosen Palette: Calm Neutrals -->
    <!-- Application Structure Plan: A guided, scenario-based learning tool. The structure is designed to build knowledge progressively: 1. A static 'Foundation' section for core concepts. 2. A 'Red Line Principle' section acting as an interactive navigation hub, visually explaining the core logic and allowing users to jump to specific scenarios. 3. A dynamic 'Interactive Scenarios' section where users select a scenario, and the content (chart, explanation, calculations) updates via JavaScript. This task-oriented approach (letting the user choose a scenario to explore) is more engaging and less overwhelming than a long, linear document. -->
    <!-- Visualization & Content Choices: 
        - Influence Levels (Goal: Inform): Presented as a structured HTML/CSS card layout instead of a plain table for better visual separation and clarity.
        - Red Line Principle (Goal: Organize/Navigate): A large visual diagram built with HTML/CSS and Tailwind, featuring clickable arrows. This serves as a central, intuitive navigation element, guiding users to the detailed content. Interaction: Clicking an arrow smoothly scrolls to the relevant scenario. Justification: This transforms a core abstract concept into a tangible, interactive map of the subject.
        - Scenarios (Goal: Compare/Change): For each of the 6 scenarios, a Chart.js bar chart visualizes the "before" and "after" shareholding percentage. Interaction: User clicks a scenario button, and JS updates the chart and the detailed text description. Justification: The bar chart provides an instant visual understanding of the change, which is more impactful than just reading numbers. Dynamically updating a single content area keeps the UI clean and focused. Library: Chart.js (Canvas).
        - CONFIRMATION: NO SVG graphics used. NO Mermaid JS used. -->
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
        }
        .tab-button.active {
            background-color: #374151; /* bg-gray-700 */
            color: white;
            border-bottom-color: transparent;
        }
        .arrow {
            position: absolute;
            width: 0;
            height: 0;
            border-style: solid;
        }
        .arrow-right {
            border-width: 10px 0 10px 15px;
            border-color: transparent transparent transparent #34d399; /* emerald-400 */
        }
        .arrow-right:hover {
            border-color: transparent transparent transparent #10b981; /* emerald-500 */
        }
        .arrow-left {
            border-width: 10px 15px 10px 0;
            border-color: transparent #f87171 transparent transparent; /* red-400 */
        }
        .arrow-left:hover {
            border-color: transparent #ef4444 transparent transparent; /* red-500 */
        }
        .chart-container {
            position: relative;
            width: 100%;
            max-width: 600px;
            margin-left: auto;
            margin-right: auto;
            height: 250px;
            max-height: 300px;
        }
        @media (min-width: 768px) {
            .chart-container {
                height: 300px;
                max-height: 350px;
            }
        }
    </style>
</head>
<body class="bg-gray-50 text-gray-800">

    <header class="bg-white shadow-sm sticky top-0 z-20">
        <div class="container mx-auto px-4 py-4">
            <h1 class="text-2xl md:text-3xl font-bold text-gray-700 text-center">长期股权投资：核算方法转换交互指南</h1>
            <p class="text-center text-gray-500 mt-1">一个为初学者设计的交互式学习工具</p>
        </div>
    </header>

    <main class="container mx-auto p-4 md:p-8">
        
        <section id="foundation" class="mb-12">
            <h2 class="text-2xl font-bold text-center mb-2 text-gray-700">第一步：理解核心基础</h2>
            <p class="text-center text-gray-600 mb-6 max-w-2xl mx-auto">在开始之前，我们需要了解投资的“话语权”分为三个等级，每个等级对应不同的记账方法。这就像一个红绿灯系统，是理解一切转换的前提。</p>
            <div class="grid md:grid-cols-3 gap-6 text-center">
                <div class="bg-white p-6 rounded-xl shadow-md border border-gray-200">
                    <div class="flex items-center justify-center w-16 h-16 mx-auto mb-4 bg-emerald-100 rounded-full">
                        <span class="text-3xl">💡</span>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-emerald-700">无重大影响 (绿灯)</h3>
                    <p class="text-gray-500 mb-2 font-mono">&lt; 20% 持股</p>
                    <p class="text-gray-600">作为小散户，只关心股价变动。采用**金融工具准则**，按市场价（公允价值）计量。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md border border-gray-200">
                    <div class="flex items-center justify-center w-16 h-16 mx-auto mb-4 bg-amber-100 rounded-full">
                        <span class="text-3xl">🤝</span>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-amber-700">重大影响 (黄灯)</h3>
                    <p class="text-gray-500 mb-2 font-mono">20% ~ 50% 持股</p>
                    <p class="text-gray-600">作为重要参与者，公司赚了我也赚，亏了我也亏。采用**权益法**核算。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md border border-gray-200">
                    <div class="flex items-center justify-center w-16 h-16 mx-auto mb-4 bg-red-100 rounded-full">
                         <span class="text-3xl">👑</span>
                    </div>
                    <h3 class="text-xl font-semibold mb-2 text-red-700">控制 (红灯)</h3>
                    <p class="text-gray-500 mb-2 font-mono">&gt; 50% 持股</p>
                    <p class="text-gray-600">你就是老板，这家公司是你的“一部分”。在母公司个别报表中采用**成本法**核算。</p>
                </div>
            </div>
        </section>

        <section id="red-line" class="mb-12 bg-white p-6 rounded-xl shadow-lg border border-gray-200">
            <h2 class="text-2xl font-bold text-center mb-2 text-gray-700">第二步：掌握“红线原则”</h2>
            <p class="text-center text-gray-600 mb-6 max-w-3xl mx-auto">所有转换的核心逻辑，都可以用一条“红线”来划分。这条线分隔了“金融工具”和“长期股权投资”。点击下面的箭头，可以直接跳转到对应场景查看详情。</p>
            <div class="relative flex justify-center items-stretch min-h-[250px] p-4">
                <div class="w-1/2 bg-emerald-50 rounded-l-lg p-4 flex flex-col justify-center items-center">
                    <h3 class="text-xl font-bold text-emerald-800">金融工具</h3>
                    <p class="text-emerald-600">(公允价值计量)</p>
                </div>
                
                <div class="absolute top-0 bottom-0 left-1/2 w-1 bg-red-500/50 transform -translate-x-1/2 flex items-center justify-center">
                     <div class="bg-red-500 text-white text-sm rounded-full px-2 py-1 transform -rotate-90">红线</div>
                </div>

                <div class="w-1/2 bg-sky-50 rounded-r-lg p-4 flex flex-col justify-center items-center">
                    <h3 class="text-xl font-bold text-sky-800">长期股权投资</h3>
                    <p class="text-sky-600">(权益法 / 成本法)</p>
                </div>

                <!-- Arrows -->
                <a href="#scenarios" onclick="displayScenario(0)" class="arrow arrow-right" style="top: 20%; left: 50%;" title="场景一：金融工具 -> 权益法"></a>
                <a href="#scenarios" onclick="displayScenario(1)" class="arrow arrow-right" style="top: 40%; left: 50%;" title="场景二：金融工具 -> 成本法"></a>
                <a href="#scenarios" onclick="displayScenario(2)" class="arrow arrow-right" style="top: 60%; left: calc(50% + 120px); transform: translateX(-50%);" title="场景三：权益法 -> 成本法"></a>
                
                <a href="#scenarios" onclick="displayScenario(3)" class="arrow arrow-left" style="top: 20%; right: calc(50% + 120px); transform: translateX(50%);" title="场景四：成本法 -> 权益法"></a>
                <a href="#scenarios" onclick="displayScenario(4)" class="arrow arrow-left" style="top: 40%; right: 50%;" title="场景五：成本法 -> 金融工具"></a>
                <a href="#scenarios" onclick="displayScenario(5)" class="arrow arrow-left" style="top: 60%; right: 50%;" title="场景六：权益法 -> 金融工具"></a>

            </div>
             <p class="text-center text-xs text-gray-400 mt-4">绿色箭头表示增资，红色箭头表示减资</p>
        </section>
        
        <section id="scenarios" class="scroll-mt-20">
            <h2 class="text-2xl font-bold text-center mb-2 text-gray-700">第三步：六大场景交互演练</h2>
            <p class="text-center text-gray-600 mb-6 max-w-2xl mx-auto">请选择一个您想学习的转换场景。下方的图表和解释将会动态更新。</p>
            
            <div class="flex flex-wrap justify-center gap-2 md:gap-3 mb-8">
                <button onclick="displayScenario(0)" data-scenario-id="0" class="tab-button px-4 py-2 text-sm md:text-base font-medium text-gray-600 bg-white rounded-lg shadow-sm border border-gray-200 hover:bg-gray-100 transition">场景一: 散户→二股东</button>
                <button onclick="displayScenario(1)" data-scenario-id="1" class="tab-button px-4 py-2 text-sm md:text-base font-medium text-gray-600 bg-white rounded-lg shadow-sm border border-gray-200 hover:bg-gray-100 transition">场景二: 散户→大老板</button>
                <button onclick="displayScenario(2)" data-scenario-id="2" class="tab-button px-4 py-2 text-sm md:text-base font-medium text-gray-600 bg-white rounded-lg shadow-sm border border-gray-200 hover:bg-gray-100 transition">场景三: 二股东→大老板</button>
                <button onclick="displayScenario(3)" data-scenario-id="3" class="tab-button px-4 py-2 text-sm md:text-base font-medium text-gray-600 bg-white rounded-lg shadow-sm border border-gray-200 hover:bg-gray-100 transition">场景四: 老板→二股东</button>
                <button onclick="displayScenario(4)" data-scenario-id="4" class="tab-button px-4 py-2 text-sm md:text-base font-medium text-gray-600 bg-white rounded-lg shadow-sm border border-gray-200 hover:bg-gray-100 transition">场景五: 老板→散户</button>
                <button onclick="displayScenario(5)" data-scenario-id="5" class="tab-button px-4 py-2 text-sm md:text-base font-medium text-gray-600 bg-white rounded-lg shadow-sm border border-gray-200 hover:bg-gray-100 transition">场景六: 二股东→散户</button>
            </div>

            <div id="scenario-content" class="bg-white p-4 md:p-8 rounded-2xl shadow-xl border border-gray-200 min-h-[400px]">
                <div id="scenario-placeholder" class="text-center text-gray-500 flex flex-col justify-center items-center h-full">
                    <svg class="w-16 h-16 mb-4 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 11.5V14m0-2.5v-6a1.5 1.5 0 113 0m-3 6a1.5 1.5 0 00-3 0v2a1.5 1.5 0 003 0m-3-6a1.5 1.5 0 013 0v6a1.5 1.5 0 01-3 0m0 0v2a1.5 1.5 0 003 0m12-6.5a1.5 1.5 0 00-3 0v6a1.5 1.5 0 003 0m-3-6a1.5 1.5 0 013 0v6a1.5 1.5 0 01-3 0m0 0v2a1.5 1.5 0 003 0m-6.5-1.5a1.5 1.5 0 00-3 0v6a1.5 1.5 0 003 0m-3-6a1.5 1.5 0 013 0v6a1.5 1.5 0 01-3 0m0 0v2a1.5 1.5 0 003 0"></path></svg>
                    <p class="text-lg">请从上方选择一个场景开始学习</p>
                </div>
            </div>
        </section>

    </main>
    
    <footer class="text-center py-8">
        <p class="text-gray-400 text-sm">&copy; 2025 交互式会计学习工具. All rights reserved.</p>
    </footer>

<script>
const scenariosData = [
    {
        title: "场景一：增资跨线 (金融工具 → 权益法)",
        subtitle: "本来是散户，现在增持成了二股东。",
        situation: "原持有A公司 10% 股权，作为“其他权益工具投资”核算。现在又买了 20%，合计持有 30%，对A公司有了重大影响。",
        redLine: "从“红线左边”跨到了“红线右边”。适用“**先卖后买**”原则。",
        chartData: { from: 10, to: 30 },
        steps: [
            {
                title: "初始状态",
                desc: "持有A公司 10% 股权，成本 $1000万，记在“其他权益工具投资”。转换日当天，这部分股权的市场价（公允价值）涨到了 $1200万。"
            },
            {
                title: "增资动作",
                desc: "又花了 $2500万，买下另外 20% 的股权。"
            },
            {
                title: "会计处理",
                desc: "1. **视同卖出**：按公允价值 $1200万 卖掉原 10% 股权，与成本 $1000万 的差额 $200万 计入“其他综合收益”。<br>2. **视同买入**：新的“长期股权投资-权益法”的入账成本由两部分构成。"
            }
        ],
        formula: {
            label: "新长投初始成本 = 原股权公允价值 + 新增投资成本",
            calc: "$1200万 + $2500万 = $3700万"
        }
    },
    {
        title: "场景二：增资跨线 (金融工具 → 成本法)",
        subtitle: "本来是散户，一把买成了大老板。",
        situation: "原持有A公司 10% 股权，作为“交易性金融资产”核算。现在又买了 50%，合计持有 60%，实现了对A公司的控制。",
        redLine: "从“红线左边”跨到了“红线右边”。同样适用“**先卖后买**”原则。",
        chartData: { from: 10, to: 60 },
        steps: [
            {
                title: "初始状态",
                desc: "持有A公司 10% 股权，成本 $1000万，记在“交易性金融资产”。转换日当天，公允价值涨到了 $1200万。"
            },
            {
                title: "增资动作",
                desc: "又花了 $6500万，买下另外 50% 的股权。"
            },
            {
                title: "会计处理",
                desc: "1. **视同卖出**：卖掉原 10% 股权，公允价值 $1200万 与原始成本 $1000万 的差额 $200万 计入“投资收益”。<br>2. **视同买入**：确定新的“长期股权投资-成本法”的入账成本。"
            }
        ],
        formula: {
            label: "新长投初始成本 = 原股权公允价值 + 新增投资成本",
            calc: "$1200万 + $6500万 = $7700万"
        }
    },
    {
        title: "场景三：增资未跨线 (权益法 → 成本法)",
        subtitle: "本来是二股东，现在增持成了大老板。",
        situation: "原持有A公司 30% 股权，按权益法核算。现在又买了 30%，合计持有 60%，实现了控制。",
        redLine: "一直在“红线右边”，没有跨线。适用“**账面价值合并**”原则。",
        chartData: { from: 30, to: 60 },
        steps: [
            {
                title: "初始状态",
                desc: "持有A公司 30% 股权。由于期间A公司盈利等，这笔投资在账本上（按权益法）的**账面价值**目前是 $3500万。"
            },
            {
                title: "增资动作",
                desc: "又花了 $4000万，买下另外 30% 的股权。"
            },
            {
                title: "会计处理",
                desc: "核心：**不需要“卖”**！因为没有跨线，不考虑市价波动，直接将两部分价值相加形成新的成本。"
            }
        ],
        formula: {
            label: "新长投初始成本 = 原股权账面价值 + 新增投资成本",
            calc: "$3500万 + $4000万 = $7500万"
        }
    },
    {
        title: "场景四：减资未跨线 (成本法 → 权益法)",
        subtitle: "本来是大老板，现在卖了一部分股份，变成了二股东。",
        situation: "原持有A公司 60% 股权，按成本法核算。现在卖掉了 30%，剩下 30%，从“控制”降级为“重大影响”。",
        redLine: "一直在“红线右边”，没有跨线。适用“**部分剥离，剩余部分改方法**”原则。",
        chartData: { from: 60, to: 30 },
        steps: [
            {
                title: "初始状态",
                desc: "持有A公司 60% 股权，成本法下的账面价值是 $7500万。"
            },
            {
                title: "减资动作",
                desc: "把其中一半（即 30% 股权）卖掉了，收到了 $4200万 现金。"
            },
            {
                title: "会计处理",
                desc: "1. **计算处置损益**：卖掉的这部分股权，对应的成本是 $7500万 * (30%/60%) = $3750万。处置收益 = $4200万 - $3750万 = $450万。<br>2. **处理剩余部分**：对剩下的 30% 股权（账面价值 $3750万）**不做任何调整**，直接从今天起，改用权益法来记账（未来适用法）。"
            }
        ],
        formula: {
            label: "剩余投资（权益法初始成本）",
            calc: "$3750万"
        }
    },
    {
        title: "场景五：减资跨线 (成本法 → 金融工具)",
        subtitle: "本来是大老板，现在几乎全卖光了，只留了一点点当散户。",
        situation: "原持有A公司 60% 股权，按成本法核算。现在卖掉了 55%，剩下 5%，既无控制也无重大影响。",
        redLine: "从“红线右边”跨到了“红线左边”。适用“**先卖后买**”原则。",
        chartData: { from: 60, to: 5 },
        steps: [
            {
                title: "初始状态",
                desc: "持有A公司 60% 股权，成本法下的账面价值是 $7500万。"
            },
            {
                title: "减资动作",
                desc: "卖掉了 55% 的股权。剩下的 5% 在今天的市场价（公允价值）是 $800万。"
            },
            {
                title: "会计处理",
                desc: "1. **视同全部卖出**：会计上假设你把整个 60% 的投资都卖了，确认整体的处置损益。<br>2. **视同买入**：剩下的 5% 股权，作为一项新的金融资产来记账。"
            }
        ],
        formula: {
            label: "新金融资产成本 = 剩余股权在转换日的公允价值",
            calc: "$800万"
        }
    },
    {
        title: "场景六：减资跨线 (权益法 → 金融工具)",
        subtitle: "本来是二股东，现在也卖得差不多了，变成了小散户。",
        situation: "原持有A公司 30% 股权，按权益法核算。现在卖掉了 20%，剩下 10%，失去了重大影响。",
        redLine: "从“红线右边”跨到了“红线左边”。适用“**先卖后买**”原则。",
        chartData: { from: 30, to: 10 },
        steps: [
            {
                title: "初始状态",
                desc: "持有A公司 30% 股权，权益法下的账面价值是 $3700万。同时，账上还有关联的“其他综合收益” $200万。"
            },
            {
                title: "减资动作",
                desc: "卖掉 20% 股权。剩下的 10% 在今天的公允价值是 $1500万。"
            },
            {
                title: "会计处理",
                desc: "1. **视同全部卖出**：确认整个 30% 投资的处置损益。之前确认的“其他综合收益” $200万 要一次性转入投资收益。<br>2. **视同买入**：剩下的 10% 股权，按其公允价值确认为新的金融资产。"
            }
        ],
        formula: {
            label: "新金融资产成本 = 剩余股权在转换日的公允价值",
            calc: "$1500万"
        }
    }
];

const scenarioContentDiv = document.getElementById('scenario-content');
let myChart = null;

function displayScenario(id) {
    const data = scenariosData[id];
    
    document.querySelectorAll('.tab-button').forEach(btn => {
        btn.classList.remove('active');
        if(btn.dataset.scenarioId == id) {
            btn.classList.add('active');
        }
    });

    let stepsHtml = data.steps.map((step, index) => `
        <div class="flex">
            <div class="flex flex-col items-center mr-4">
                <div>
                    <div class="flex items-center justify-center w-8 h-8 bg-gray-700 text-white rounded-full font-bold">${index + 1}</div>
                </div>
                <div class="w-px h-full bg-gray-300"></div>
            </div>
            <div class="pb-8">
                <p class="mb-2 text-lg font-semibold text-gray-700">${step.title}</p>
                <p class="text-gray-600">${step.desc}</p>
            </div>
        </div>
    `).join('');

    scenarioContentDiv.innerHTML = `
        <h3 class="text-xl md:text-2xl font-bold text-gray-800 mb-1">${data.title}</h3>
        <p class="text-gray-500 mb-4">“${data.subtitle}”</p>
        
        <div class="grid lg:grid-cols-2 gap-8 items-start">
            <div>
                <div class="mb-6">
                    <p class="font-semibold text-gray-700">情况简介：</p>
                    <p class="text-gray-600">${data.situation}</p>
                </div>
                <div class="mb-6 p-3 bg-yellow-50 border-l-4 border-yellow-400 rounded-r-lg">
                    <p class="font-semibold text-yellow-800">红线分析：</p>
                    <p class="text-yellow-700">${data.redLine}</p>
                </div>
                <div class="chart-container">
                    <canvas id="scenarioChart"></canvas>
                </div>
            </div>

            <div>
                <h4 class="text-lg font-bold text-gray-700 mb-4 border-b pb-2">会计处理步骤</h4>
                ${stepsHtml}

                <div class="mt-4 p-4 bg-emerald-50 rounded-lg text-center">
                    <p class="text-emerald-700 font-semibold">${data.formula.label}</p>
                    <p class="text-2xl font-bold text-emerald-800 tracking-wider">${data.formula.calc}</p>
                </div>
            </div>
        </div>
    `;

    renderChart(data.chartData);
}

function renderChart(chartData) {
    const ctx = document.getElementById('scenarioChart').getContext('2d');
    if (myChart) {
        myChart.destroy();
    }
    myChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: ['转换前', '转换后'],
            datasets: [{
                label: '持股比例 (%)',
                data: [chartData.from, chartData.to],
                backgroundColor: [
                    'rgba(251, 146, 60, 0.6)', // orange-400
                    'rgba(59, 130, 246, 0.6)'  // blue-500
                ],
                borderColor: [
                    'rgba(251, 146, 60, 1)',
                    'rgba(59, 130, 246, 1)'
                ],
                borderWidth: 1
            }]
        },
        options: {
            responsive: true,
            maintainAspectRatio: false,
            scales: {
                y: {
                    beginAtZero: true,
                    max: 100,
                    ticks: {
                        callback: function(value) {
                            return value + '%'
                        }
                    }
                }
            },
            plugins: {
                legend: {
                    display: false
                },
                tooltip: {
                    callbacks: {
                        label: function(context) {
                            return `持股: ${context.raw}%`;
                        }
                    }
                }
            },
            animation: {
                duration: 1000,
                easing: 'easeInOutQuart'
            }
        }
    });
}

// Automatically display the first scenario on page load as a gentle start
window.onload = () => {
   // displayScenario(0);
};

</script>
</body>
</html>
